﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyBoss1Gun : EnemyBaseFixed
{
    public float startIdleTime = 0.3f;
    public GameObject remainGameObject;

    private void Awake()
    {
        base.Init();
        animator.enabled=false;
    }


    private void Start()
    {
        if (remainGameObject != null)
        {
            remainGameObject.SetActive(false);
        }
        //Run();
        Stop();
    }

    private void FixedUpdate()
    {
        base.CommonFixedUpdate();
    }
    protected void UpdateStateNone(bool stateChanged, EnumState inState, out EnumState outState)
    {
        outState = EnumState.Working;
        animator.enabled = false;
    }
    protected void UpdateStateWorking(bool stateChanged, EnumState inState, out EnumState outState)
    {
        outState = inState;

        animator.enabled = true;

    }

    protected override void UpdateStateDie(bool stateChanged, EnumState inState, out EnumState outState)
    {
        outState = inState;

        StopWork();
        Boom();
        if (remainGameObject != null)
        {
            remainGameObject.SetActive(true);
        }

    }

    private void OnFire()
    {
        Fire();
    }

    private void Fire()
    {
        if (bulletPrefab != null)
        {
            Vector2 firePoint = transform.position;
            firePoint += Vector2.left * 0.6875f;
            Instantiate(bulletPrefab, firePoint, Quaternion.identity);
        }
    }
    private void StartWork()
    {
        state = EnumState.Working;
    }
    private void StopWork()
    {
        state = EnumState.None;

    }

    public override void Run()
    {
        if (!running)
        {
            running = true;
            StartWork();
        }
    }

    public override void Stop()
    {
        base.Stop();
    }
}
